package com.cinema.service;

import com.cinema.entity.hall.Hall;
import com.cinema.util.DataStore;

import java.util.List;

/**
 * 放映厅服务类，处理放映厅相关业务逻辑
 */
public class HallService {
    private final DataStore dataStore = DataStore.getInstance();
    private final List<Hall> hallList = dataStore.getHallList();

    /**
     * 查看所有放映厅
     */
    public void listAllHalls() {
        if (hallList.isEmpty()) {
            System.out.println("❌ 暂无放映厅数据");
            return;
        }

        System.out.println("\n===== 放映厅列表 =====");
        for (Hall hall : hallList) {
            System.out.printf("放映厅ID：%s，名称：%s，座位：%d行%d列，总座位数：%d%n",
                    hall.getHallId(), hall.getHallName(),
                    hall.getRowCount(), hall.getColCount(),
                    hall.getRowCount() * hall.getColCount());
        }
    }

    /**
     * 根据ID查找放映厅
     */
    public Hall findHallById(String hallId) {
        for (Hall hall : hallList) {
            if (hall.getHallId().equals(hallId)) {
                return hall;
            }
        }
        return null;
    }

    /**
     * 添加放映厅
     */
    public void addHall(Hall hall) {
        hallList.add(hall);
        dataStore.updateHallList();
    }
}

